/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.web.gwt.form.server.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;

import com.genia.toolbox.web.mvc.controller.AbstractCustomFormController;

/**
 * controller that print the correct iframe.
 */
public class GwtFormController
    extends AbstractCustomFormController
{

  /**
   * the name of the view that redirects to form.jsp.
   */
  private static final String FORM_VIEW = "com.genia.toolbox.web.gwt.form.server.controller.GwtFormController.view";



  /**
   * Process form submission request. This method retrieve the identifier of the
   * uploaded file to preview and returns it. It does not need to make any
   * security check because the files informations are handled by the session of
   * the user, so if a use has a file information, he is authorized to access
   * the file.
   * 
   * @param request
   *          current servlet request
   * @param response
   *          current servlet response
   * @param form
   *          form object with request parameters bound onto it
   * @param bindException
   *          holder without errors (subclass can add errors if it wants to)
   * @return always <code>null</code>
   * @see org.springframework.web.servlet.mvc.AbstractFormController#processFormSubmission(javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse, java.lang.Object,
   *      org.springframework.validation.BindException)
   */
  @Override
  protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object form, BindException bindException)
  {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("formIdentifier", form);
    return new ModelAndView(FORM_VIEW, model);
  }

}
